<template>
  <div
    class="custom-modal-wrap"
    ref="modalWrapRef"
    v-if="visible"
    @click="onClose"
  >
    <div class="custom-modal" @click.stop>
      <div class="custom-modal-content">
        <div class="close-button" @click="onClose">
          <CloseCircleOutlined />
        </div>
        <div class="video-wrap" v-if="videoInfo.length > 0">
          <div class="video">
            <flvVideo
              :videoItem="videoInfo[0]"
              :videoIndex="999"
              v-if="videoInfo[0].video_type == 'flv'"
            />
            <hlsVideo
              :videoItem="videoInfo[0]"
              :videoIndex="999"
              v-if="videoInfo[0].video_type == 'hls'"
            />
          </div>
        </div>
        <div v-else class="empty-wrap">设备已离线</div>
      </div>
    </div>
  </div>
</template>

<script>
import {
  defineComponent,
  reactive,
  toRefs,
  computed,
  watch,
  toRaw,
  ref,
  nextTick,
} from "vue";
import flvVideo from "../VideoCam/flvVideo.vue";
import hlsVideo from "../VideoCam/hlsVideo.vue";
import { CloseCircleOutlined } from "@ant-design/icons-vue";
export default defineComponent({
  name: "MonitorModal",
  components: { flvVideo, hlsVideo, CloseCircleOutlined },
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    videoInfo: {
      type: Array,
      default: () => [],
    },
  },

  setup(props, context) {
    const state = reactive({});

    const onClose = () => {
      context.emit("onClose");
    };

    return {
      ...toRefs(state),
      onClose,
    };
  },
});
</script>

<style lang="less" scoped>
.custom-modal-wrap {
  width: 100vw;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  background-color: rgba(0, 0, 0, 0.45);

  .custom-modal {
    width: 120rem;
    height: 80rem;
    margin: 6rem auto 0 auto;
    border-radius: 0.8rem;
    overflow: hidden;

    :deep(.border-box-content) {
      padding: 1.2rem;
    }

    .custom-modal-content {
      width: 100%;
      height: 100%;
      background-color: rgba(0, 77, 145, 0.9);
      border-radius: 3rem;
      box-shadow: inset 0 0 1rem #fff;
      backdrop-filter: blur(0.3rem);
      padding: 2rem;

      .close-button {
        position: absolute;
        top: 0.5rem;
        right: 1rem;
        width: 4rem;
        height: 4rem;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        font-size: 2rem;
      }

      .video-wrap {
        overflow: hidden auto;
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: center;

        .video {
          width: 76rem;
          height: 100%;
        }
      }

      .empty-wrap {
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 1.6rem;
      }
    }
  }
}
</style>
